package com.example.wanglv.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.wanglv.MyAdpater;
import com.example.wanglv.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ListFragment extends Fragment {
    MyAdpater myAdpater;
    ListView listView;
    List<Map<String,String>>mapList;
    String[] name=new String[]{"张三","李四","王五"};
    String[] money=new String[]{"30人民币","40人民币","35人民币"};
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v=inflater.inflate(R.layout.myfargment1,null);
        listView=v.findViewById(R.id.listview);
        mapList=new ArrayList<>();
        list();
        myAdpater=new MyAdpater(getActivity(),mapList);
        listView.setAdapter(myAdpater);
        return v;
    }
    void list(){
        Map<String,String>map;
        for (int i=0;i<3;i++){
            map=new HashMap<>();
            map.put("name",name[i]);
            map.put("money",money[i]);
            mapList.add(map);
        }

    }

}
